const toMapAPP = (latitude, longitude, name) => {
	let url = '';
	if (plus.os.name == 'Android') {
		//判断是安卓端
		plus.nativeUI.actionSheet({
				//选择菜单
				title: '选择地图应用',
				cancel: '取消',
				buttons: [{
					title: '百度地图'
				}, {
					title: '高德地图'
				}]
			},
			function(e) {
				switch (e.index) {
					//下面是拼接url,不同系统以及不同地图都有不同的拼接字段
					case 1:
						url =
							`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`;
						break;
					case 2:
						url =
							`androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
						break;
					default:
						break;
				}
				if (url != '') {
					url = encodeURI(url);
					//plus.runtime.openURL(url,function(e){})调起手机APP应用
					plus.runtime.openURL(url, function(e) {
						plus.nativeUI.alert("本机未安装指定的地图应用");
						// plus.runtime.openURL('https://mobile.amap.com/', function(err) {
						// 	console.log(err);
						// });
					});
				}
			}
		);
	} else {
		plus.nativeUI.actionSheet({
				title: "选择地图应用",
				cancel: "取消",
				buttons: [{
					title: "百度地图"
				}, {
					title: "高德地图"
				}]
			},
			function(e) {
				switch (e.index) {
					case 1:
						url =
							`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;
						break;
					case 2:
						url =
							`iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
						break;
					default:
						break;
				}
				if (url != "") {
					url = encodeURI(url);
					plus.runtime.openURL(url, function(e) {
						plus.nativeUI.alert("本机未安装指定的地图应用");
					});
				}
			}
		)
	}
}
// ios　google
// plus.runtime.launchApplication({ action: 'comgooglemaps://' }, function(err) {
// 	console.log(err);
// 	uni.showModal({
// 		title: '请检查是否安装谷歌地图'
// 	});
// });
// android google
// plus.runtime.launchApplication({ pname: 'com.google.android.apps.maps', 
// extra: { url: 'google.streetview:cbll=46.414382,10.013988' } }, function(e) {
// 	console.log(e);
// 	uni.showModal({
// 		title: '请检查是否安装谷歌地图'
// 	});
// });
export {
	toMapAPP
}
